#include <linux/init.h>
#include <linux/module.h>
#include <linux/kdev_t.h>
#include <linux/fs.h>

static int major = 101;
static int minor= 0;
static dev_t devno;

static int hello_init(void)
{
	int result = 0;

	printk(KERN_ALERT "hello_init \n");
	devno = MKDEV(major, minor);

	result = register_chrdev_region(devno, 1, "test_dev");
	if(result < 0) {
		printk("register chardev region fail \n");
		return result;
	}
	return 0;
}

static void hello_exit(void)
{
	printk(KERN_ALERT "hello_exit \n");
	unregister_chrdev_region(devno, 1);
	return;
}

MODULE_LICENSE("Dual BSD/GPL");

module_init(hello_init);
module_exit(hello_exit);
